package common

const (
	SuccessCode = 200
	ErrorCode   = 500
)

type JsonResult struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func Json(code int, msg string, data interface{}) *JsonResult {
	return &JsonResult{
		Code:    code,
		Message: msg,
		Data:    data,
	}
}

func Success(data interface{}) *JsonResult {
	return &JsonResult{
		Code: SuccessCode,
		Data: data,
	}
}

func Error(msg string) *JsonResult {
	return &JsonResult{
		Code:    ErrorCode,
		Message: msg,
	}

}
